<template>
    <div class="con">
        <img src="../assets/images/logo.png" alt="" class="logo">
        <!-- 绳子头部定位 -->
        <div class="rope">
            <img src="../assets/images/ropeTop.png" alt="">                
        </div>  
        <!-- 木块 标题-->
        <div class="woodList">
            <div class="woods" v-for="item in gift_list" @click="ok(item.id,item.title_img)">   
                      
                  <img src="../assets/images/wood_title.png" alt="" class="wood">
                  <img :src="siteImageUrl+item.title_img" alt="" class="shopTitle" > 
                          
            </div>  
            <div class="ropeFooter">
                <img src="../assets/images/ropeFooter.png" alt="">
            </div>    
        </div>
          
    </div>
</template>

<script>
export default {
  name: "index",
  data() {
        return {
            gift_list:[]

        };
  },
  beforeCreate() {
        document.getElementsByTagName("body")[0].className = "bg_MyPoints";
  },
  methods:{
     ok(id,gift_img){
        this.$router.push({ name: "giftDetail", params: { id:id,gift_img: gift_img}});
        localStorage.setItem('gift_img', gift_img);


     }
  },
  mounted: function() {
        var param = new URLSearchParams();
        param.append("member_id", $.cookie('osc_member_id'));
        param.append("token", $.cookie('osc_member_token'));
        this.axios({
            method: "post",
            url: `${this.siteUrl}/piaowu/api/gift_category_list`,
            data: param
        })
        .then(response => {
            if (response.data.status == 1) {
                this.gift_list=response.data.data;
                console.log(this.gift_list);               
            } else {
                alert("请求失败："+response.data.msg);
            }
        })
        .catch(function(error) {
            console.log(error);
        });
         
    }
 
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.con {
  text-align: center;
  position: relative;
}
.con .logo{
    width: 34%;
    position: absolute;
    left: 50%;
    transform: translate(-50%,30%);

}
header img {
  width: 120px;
}
header select {
  width: 50%;
  height: 30px;
  text-indent: 10px;
  position: absolute;
  left: 50%;
  transform: translate(-50%, 0%);
  z-index: 999;
}
.rope {
  width: 100%;
  position: absolute;
  top: 0px;
  left: 0px;
}
.rope img {
  position: absolute;
  left: 10%;
  width: 80%;
  height: 118px;
}

/* 木板标题 */
.woodList {
  width: 90%;
  position: absolute;
  left: 5%;
  top: 125px;
}

.woodList .wood,
.woodList .woods {
  width: 100%;
  z-index: 999;
}
.woodList .woods {
  margin-top: -15px;
  position: relative;
}

.woodList .shopTitle {
  position: absolute;
  left: 50%;
  transform: translate(-50%,0%);
  top: -4%;
  width: 50%;
}
.woodList .ropeFooter img {
  width: 94%;
  left: 4%;
  margin-top: -20px;
  position: absolute;
}
</style>
